package org.peterf.foxish.util;

public class Pair<A, B> {

    public A first;

    public B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    @SuppressWarnings("unchecked")
    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof Pair))
            return false;
        Pair<A, B> ref;
        try {
            ref = (Pair<A, B>) o;
        } catch (ClassCastException e) {
            return false;
        }
        return first.equals(ref.first) && second.equals(ref.second);
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + first.hashCode();
        result = 31 * result + second.hashCode();
        return result;
    }

}
